package android.support.v4.os;

import android.util.Log;


//ok
public class ELog extends EHook {

    @Override
    public String getClassName() {
        return Log.class.getName();
    }

	private static final String[] filterTAG = {"Trace"};

	@Override
	public void hook() {
//		int println(int priority, String tag, String msg)
		findAndHookMethod("println", int.class, String.class, String.class, this);
//		int println_native(int bufID, int priority, String tag, String msg);
		findAndHookMethod("println_native", int.class, int.class, String.class, String.class, this);
	}

	@Override
	protected boolean before(String methodName, Object[] args, MethodHookParam param) {
		String tag = null;
		if(methodName.equals("println_native")){
			tag = (String) args[2];
		} else if(methodName.equals("println")){
			tag = (String) args[1];
		}
		if(tag != null){
			for (String s : filterTAG) {
				if (s.equals(tag))
					param.setResult(0);
			}
		}
		return false;
	}

}
